"""卖家对话消息数据模型"""

from datetime import datetime
from typing import Optional

from pydantic import BaseModel, ConfigDict


class SellerMessageQueryModel(BaseModel):
    """卖家消息查询参数"""

    conversation_id: Optional[str] = None  # ✅ 新增：支持按会话ID查询
    seller_id: Optional[str] = None
    seller_name: Optional[str] = None
    client_id: Optional[str] = None
    item_id: Optional[str] = None
    message_type: Optional[str] = None
    direction: Optional[str] = None
    start_time: Optional[datetime] = None
    end_time: Optional[datetime] = None


class SellerMessageModel(BaseModel):
    """卖家消息返回模型"""

    model_config = ConfigDict(from_attributes=True)

    id: Optional[int] = None
    conversation_id: Optional[str] = None
    message_id: Optional[str] = None
    client_id: Optional[str] = None
    client_name: Optional[str] = None
    account_user_id: Optional[str] = None
    seller_id: Optional[str] = None
    seller_name: Optional[str] = None
    item_id: Optional[str] = None
    item_title: Optional[str] = None
    message_type: Optional[str] = None
    direction: Optional[str] = None
    message_content: Optional[str] = None
    message_extra: Optional[str] = None
    content_type: Optional[str] = None
    custom_content_type: Optional[int] = None
    read_status: Optional[int] = None  # ✅ 已读状态（1=未读，2=已读）
    message_time: Optional[datetime] = None
    create_time: Optional[datetime] = None


class SellerMessageCreateModel(BaseModel):
    """创建卖家消息模型"""

    conversation_id: Optional[str] = None
    message_id: Optional[str] = None
    client_id: str
    client_name: Optional[str] = None
    account_user_id: Optional[str] = None
    seller_id: str
    seller_name: Optional[str] = None
    item_id: Optional[str] = None
    item_title: Optional[str] = None
    message_type: Optional[str] = 'text'
    direction: Optional[str] = 'recv'
    message_content: Optional[str] = None
    message_extra: Optional[str] = None
    message_time: datetime
